<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改类别信息</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.all.js"></script>
    <script src="/js/jquery-3.3.1.min.js"></script>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date1'
            });
        });
        var $ = layui.jquery;
        $(function(){
            $("#b").click(function () {
                xiugai();
                parent.location.href="/getProgory";
            });
            $("#q").click(function () {
                parent.location.href="/getProgory";
            })
        });
        function xiugai() {
            var categoryid= $("#categoryid").val(); //员工ID
            var categoryname= $("#categoryname").val();//工作类型
            var categorylevel=$("#categorylevel").val();//工作状态
            var parentid=$("#parentid").val();//试用期
            var show=$("#show").val();//转正日期
            var shownumber=$("#shownumber").val();
            var adverpic=$("#adverpic").val();
            var status=$("#status").val();
            var url=$("#url").val();
            $.ajax({
                url : "/goUpdate",
                type : "POST",
                data : JSON.stringify({   //转JSON字符串
                    "categoryid":categoryid,
                    "categoryname":categoryname,
                    "categorylevel":categorylevel,
                    "parentid":parentid,
                    "show":show,
                    "shownumber":shownumber,
                    "adverpic":adverpic,
                    "status":status,
                    "url":url
                }),
                dataType : 'json',
                contentType : 'application/json;charset=UTF-8', //contentType很重要
                success : function(i) {
                    if (i==1){
                        alert("<--- 修改成功 --->");
                        location.reload();
                    }else {
                        alert("<--- 修改失败 --->");
                    }
                }
            });
        }
    </script>
</head>
<body>
<div class="layui-full">
    <div class="layui-tab-content" style="height: 450px;">
        <div class="layui-row" style="height:200px;width: 900px">
            <div style="margin-top: 20px">类别信息编辑</div>
            <form class="layui-form" id="aform" action="" method="" th:each="cate:${categoryById}">
                <input type="text" id="categoryid" name="categoryid" autocomplete="off" th:value="${cate.categoryid}" style="display: none">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">类别名称：</label>
                        <div class="layui-input-inline">
                            <input id="categoryname" name="categoryname" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.categoryname}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">类别级别：</label>
                        <div class="layui-input-inline">
                            <input id="categorylevel" name="categorylevel" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.categorylevel}">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">类别父ID：</label>
                        <div class="layui-input-inline">
                            <input id="parentid" name="parentid" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.parentid}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">是否显示：</label>
                        <div class="layui-input-inline">
                            <input id="show" name="show" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.show}">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">显示序号：</label>
                        <div class="layui-input-inline">
                            <input id="shownumber" name="shownumber" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.shownumber}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">广告图片：</label>
                        <div class="layui-input-inline">
                            <input id="adverpic" name="adverpic" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.adverpic}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">状态：</label>
                        <div class="layui-input-inline">
                            <input id="status" name="status" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.status}">
                            <!--<div class="layui-form-label txt" th:text="${categoryById.status}"></div>-->
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">URL：</label>
                        <div class="layui-input-inline">
                            <input id="url" name="url" lay-verify="title" autocomplete="off"
                                   class="layui-input"  th:value="${cate.url}">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-primary" id="b"
                                style="background-color: #01AAED;color: #FFFFFF;margin-left: 120px">
                            保存
                        </button>

                        <button type="button" class="layui-btn layui-btn-primary" id="q" style="left: 40px">
                            取消
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use('form',function () {
        var form=layui.form;
    })
</script>

</body>
</html>